/*============================================================================
 PROJECT: TalkWrench
 FILE:    PickPhotoView.h
 AUTHOR:  Nguyen Minh Khoai
 DATE:    2/20/13
 =============================================================================*/

/*============================================================================
 IMPORT
 =============================================================================*/
#import <UIKit/UIKit.h>

typedef enum {
    kPhotoPickerTypeAvatar,
    kPhotoPickerTypeOthers
} PhotoPickerType;

/*============================================================================
 MACRO
 =============================================================================*/
typedef void(^PickPhotoViewCallback) (UIImage *pickedImage, BOOL cancel);
typedef void(^GetPhotoAssetURLCallback) (NSURL *pickedImageURL);

/*============================================================================
 PROTOCOL
 =============================================================================*/
@class PickPhotoView;
@protocol PickPhotoViewDelegate <NSObject> 
@optional
- (void)imagePickerView:(PickPhotoView *)picker didPickedImage:(UIImage *)image ;
- (void)didCancelPicker:(PickPhotoView *)picker;
@end

/*============================================================================
 Interface:   PickPhotoView
 =============================================================================*/

@interface PickPhotoView : UIView<UINavigationControllerDelegate, UIImagePickerControllerDelegate> {
    __weak id<PickPhotoViewDelegate> delegate;
    UIViewController    *holderViewController;
    BOOL    visibling;
    NSOperationQueue *queue;
    UIImage *selectedImage;
}

@property (nonatomic, copy)     PickPhotoViewCallback    completionCallback;
@property (nonatomic, copy)     GetPhotoAssetURLCallback getPhotoAssetURLCallback;
@property (nonatomic, weak)     id<PickPhotoViewDelegate> delegate;
@property (nonatomic, strong)   UIViewController    *holderViewController;
@property (strong, nonatomic)   IBOutlet UIView *backgroundView;
@property (nonatomic, strong)   UIImage *selectedImage;
@property (assign, nonatomic)   PhotoPickerType pickerType;

+ (PickPhotoView *)sharedPickPhotoView;
- (IBAction)didTouchedOnPickPhotoButton:(id)sender;
- (void)showOnViewController:(UIViewController *)controller;
- (void)showOnViewController:(UIViewController *)controller resultBlock:(PickPhotoViewCallback)callback;
- (void)showOnViewController:(UIViewController *)controller forType:(PhotoPickerType)type resultBlock:(PickPhotoViewCallback)callback;
- (void)hide;
- (IBAction)didTouchedCancelButton:(id)sender;

@end
